# sprite = codesters.Rectangle(x, y, width, height, "color")
sprite = codesters.Rectangle(100, 100, 100, 200, "blue")
sprite.set_opacity(.3)
stage.set_background("grid")
# sprite = codesters.Rectangle(x, y, width, height, "color")
sprite = codesters.Rectangle(100, 100, 100, 50, "blue")
t = codesters.Teacher()
params = t.get_parameters_for_function('Rectangle')
try:
tval1 = sprite.get_x()
tval2 = sprite.get_y()
except:
tval1 = "DNE"
tval2 = "DNE"
try:
tval3 = int(params[0][2])
except:
tval3 = "DNE"
try:
tval4 = int(params[0][3])
except:
tval4 = "DNE"
t1 = TestObjective()
# t1.add_success(tval1 == 25 and tval2 == 50, "Great job debugging the program!")
# t1.add_failure(tval1 == "DNE" or tval2 == "DNE", "Oops! Did you delete the star?")
t1.add_failure(tval1 != 100 and tval1 != "DNE", "Oops! Did you change the x-coordinate?")
t1.add_failure(tval2 != 100 and tval2 != "DNE", "Oops! Did you change the y-coordinate?")
t2 = TestObjective()
t2.add_failure(tval3 == "DNE", "Oops! Did you delete the rectangle?")
t2.add_failure(tval3 != 100 and tval3 !="DNE", "Oops! It looks like you changed the width parameter. Try changing height. ")
t3 = TestObjective()
t3.add_success(tval4 == 200, "Great job debugging the program!")
t3.add_failure(tval4 == "DNE", "Oops! Did you delete the rectangle?")
t3.add_failure(tval4 < 200, "Try increasing the height parameter!")
t3.add_failure(tval4 > 200, "Oops! THat's too high! Try decreasing the height parameter.")
t3.add_failure(tval4 != 200 and tval4 !="DNE", "Try changing the fourth parameter to the correct radius.")
tester = TestManager()
tester.add_test_list([t1, t2, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)